<?php
use yii\helpers\Html;
?>
<table id="w0" class="table table-striped table-bordered detail-view">
    <tbody>
    <tr><th>等级</th><td><?php echo $level ?></td></tr>

    <?php if( !empty($parentCategory )){ ?>
        <tr><th>父类</th><td>
                <?php
                $a = Html::a( $parentCategory->title,
                    [ 'view',
                        'id' => $parentCategory->id,
                        'level' => $parentLevel],
                    ['class' => 'btn btn-primary'],
                    ['style' => 'margin:5px 10px']
                );

                echo $a . '    ';
                ?>
            </td></tr>
    <?php } ?>

    <?php if( !empty($childCategories )){ ?>
        <tr><th>子类</th><td>
                <?php
                foreach( $childCategories as $cat ){
                    $a = Html::a( $cat['title'],
                        [ 'view', 'id' => $cat['id'],'level' => $childLevel],
                        ['class' => 'btn btn-primary'],
                        ['style' => 'margin:5px 10px']
                    );

                    echo $a . '    ';
                }
                ?>
            </td></tr>
    <?php } ?>

    </tbody>
</table>